package com.gqs.bookstore.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@SuppressWarnings("serial")
@WebServlet("/logout.do")
public class LogoutServlet extends BaseServlet {
	protected void logout(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		
		if (session != null) {
			session.removeAttribute("current_user");
			session.invalidate();
			response.sendRedirect("login.do?m=showLogin");
		} else {
			response.sendRedirect("login.do?m=showLogin");
		}
	}
	
}
